import 'package:get/get.dart';
import 'package:live_music/http/http_utils.dart';
import 'package:live_music/models/response/countInfo_response.dart';
import 'package:live_music/models/user_info_model.dart';
import 'package:live_music/models/user_setting_model.dart';
import 'package:live_music/services/userService.dart';
import 'package:live_music/utils/toast_utils.dart';

class OtherUserInfoController extends GetxController {
  final userInfo = UserInfoModel().obs;
  final countInfo = CountInfoResponse().obs;
  final userSetting = UserSettingModel().obs;
  void getUserInfo(data) async {
    try {
      Map<String, dynamic> result = await UserService.getOtherUserInfo(data);
      userInfo.value = UserInfoModel.fromJson(result['body']);
    } catch (error) {
      ToastUtils.showToast(error['retdesc']);
    }
  }

  void loadCountInfo(data) async {
    try {
      Map<String, dynamic> result = await UserService.getCountInfo(data);
      countInfo.value = CountInfoResponse.fromJson(result['body']);
    } catch (error) {
      ToastUtils.showToast(error['retdesc']);
    }
  }

  void loadUserSetting(data) async {
    try {
      Map<String, dynamic> result = await UserService.getUserSetting(data);
      userSetting.value = UserSettingModel.fromJson(result['body']);
    } catch (error) {
      ToastUtils.showToast(error['retdesc']);
    }
  }
}
class ClickOtherUserInfoController extends GetxController {
  final userInfo = UserInfoModel().obs;
  final countInfo = CountInfoResponse().obs;
  final userSetting = UserSettingModel().obs;
  void getUserInfo(data) async {
    try {
      Map<String, dynamic> result = await UserService.getOtherUserInfo(data);
      userInfo.value = UserInfoModel.fromJson(result['body']);
    } catch (error) {
      ToastUtils.showToast(error['retdesc']);
    }
  }

  void loadCountInfo(data) async {
    try {
      Map<String, dynamic> result = await UserService.getCountInfo(data);
      countInfo.value = CountInfoResponse.fromJson(result['body']);
    } catch (error) {
      ToastUtils.showToast(error['retdesc']);
    }
  }

  void loadUserSetting(data) async {
    try {
      Map<String, dynamic> result = await UserService.getUserSetting(data);
      userSetting.value = UserSettingModel.fromJson(result['body']);
    } catch (error) {
      ToastUtils.showToast(error['retdesc']);
    }
  }
}
